package com.yanqu.road.logic.activity.foxcard.game.sorcery;

import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;

/**
 * 选定手牌中的一张卡牌，复制并生成{0}张一样的牌。
 */
public class FoxCardSorceryUse6 extends FoxCardSorceryUseBase {
    @Override
    protected boolean sorceryUse(FoxCardGameLogic gameLogic) {
        if (gameLogic.getGameData().getHandCards().isEmpty()) {
            return false;
        }
        if (targetIdList.size() != 1) {
            return false;
        }
        Integer targetId = targetIdList.get(0);
        int num = sorceryConfig.getParamList().get(0);

        if (num <= 0) {
            return false;
        }

        FoxHandCard foxHandCard = gameLogic.getGameData().getHandCards().stream().filter(handCard -> handCard.getId() == targetId).findFirst().orElse(null);
        if (foxHandCard == null) {
            return false;
        }

        for (int i = 0; i < num; i++) {
            gameLogic.addNewHandCard(foxHandCard.getPoint(), foxHandCard.getColor(), foxHandCard.getReinforceEffect(), foxHandCard.getVersionEffect(), foxHandCard.getSealEffect());
        }

        return true;
    }
}
